package com.group9.controller;

import com.group9.dto.FruitDetail;
import com.group9.service.FruitDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Lcouncillor on 2020/5/23.
 */
@Controller
@RequestMapping(value = "fruitdetail")
public class FruitDetailController {

    @Autowired
    FruitDetailService fruitDetailService;

    @RequestMapping(value = "{id}")
    @ResponseBody
    public FruitDetail getFruitDetail(@PathVariable("id") Integer fruitId){
        return fruitDetailService.selectFruitDetailByFruitId(fruitId);
    }

    @RequestMapping(value = "fruit/{id}")
    public String toFruitDetail(@PathVariable("id") Integer fruitId){
        return "forward:/fruitdetails.html";
    }
}
